import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/refresh")
public class RefreshServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setHeader("refresh","1"); // 表示 每一秒刷新一次
        resp.getWriter().write(""+System.currentTimeMillis()); // 虽然是每秒刷新一次, 但也不是精确的 1000 ms, 要略多一点
        // 浏览器发送请求到服务器返回响应 也需要时间

    }
}
